import { forEach, isObject, getType } from "../utils";

/**
 * 合并对象
 * @param {*} config1 
 * @param {*} config2 
 * @returns 
 */
export default function mergeConfig(config1, config2) {
  const config = {};
  const headerKeys = Object.keys(Object.assign({}, config1, config2));
  forEach(headerKeys, function (prop) {
    if (isObject(config1[prop]) && isObject(config2[prop])) {
      config[prop] = mergeConfig(config1[prop], config2[prop]);
    } else {
      config[prop] = config2[prop];
    }
  })
  return config;
}